Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/serial/serial.c: adapt to the iovec-based api #14898

Merged
merged 3 commits into from
Jan 14, 2025

Conversation

yamt
Copy link
Contributor

@yamt yamt commented Nov 22, 2024

Summary

drivers/serial/serial.c: adapt to the iovec-based api

This would fix readv/writev issues mentioned in
#12674.
(only for this specific driver though. with this approach,
we basically have to fix every single drivers and
filesystems.)

Impact

Testing

Lightly tested on the serial console, using micropython REPL
on toywasm with esp32s3-devkit:toywasm, which used to be
suffered by the readv issue.

@github-actions github-actions bot added Area: Drivers Drivers issues Area: File System File System issues Size: M The size of the change in this PR is medium labels Nov 22, 2024
@nuttxpr
Copy link

nuttxpr commented Nov 22, 2024

[Experimental Bot, please feedback here]

Fill In The Commit Message: This PR contains a Commit with an Empty Commit Message. Please fill in the Commit Message with the PR Summary.

No, this PR does not fully meet the NuttX requirements. While it provides a summary and mentions testing, it lacks crucial details.

Here's a breakdown of missing information:

  • Summary: While the "what" is explained, the "how" is missing. The summary should explain precisely how serial.c is adapted to the iovec-based API. What code changes were made? What functions were modified?
  • Impact: This section is entirely empty. All impact points need to be addressed, even if the answer is "NO". For example, if no user impact is expected, explicitly state "Impact on user: NO". The developer needs to consider and document every potential impact. Given that this PR mentions fixing a bug, there's likely impact on compatibility (fixing a bug improves compatibility, arguably).
  • Testing: The testing description is insufficient. "Lightly tested" is vague. What specific tests were run? What commands were issued? The provided information about the platform is good, but the actual logs are missing. Empty code blocks are provided for "Testing logs before change" and "Testing logs after change" - these must be populated with actual output.

Specifically, the author needs to:

  • Elaborate on the implementation details in the summary.
  • Complete the Impact section, addressing each point individually.
  • Provide concrete testing details and include the actual logs before and after the change.

@yamt yamt force-pushed the readv-serial branch 4 times, most recently from b94fb12 to 2937e17 Compare November 22, 2024 07:06
include/nuttx/fs/uio.h Show resolved Hide resolved
fs/vfs/fs_read.c Show resolved Hide resolved
fs/vfs/fs_uio.c Outdated Show resolved Hide resolved
fs/vfs/fs_uio.c Show resolved Hide resolved
fs/vfs/fs_uio.c Outdated Show resolved Hide resolved
fs/vfs/fs_uio.c Show resolved Hide resolved
fs/vfs/fs_uio.c Outdated Show resolved Hide resolved
fs/vfs/fs_uio.c Outdated Show resolved Hide resolved
drivers/misc/dev_zero.c Outdated Show resolved Hide resolved
drivers/misc/dev_zero.c Show resolved Hide resolved
drivers/loop/loop.c Outdated Show resolved Hide resolved
drivers/misc/dev_null.c Outdated Show resolved Hide resolved
fs/vfs/fs_uio.c Outdated Show resolved Hide resolved
fs/vfs/fs_uio.c Show resolved Hide resolved
fs/vfs/fs_uio.c Outdated Show resolved Hide resolved
drivers/serial/serial.c Show resolved Hide resolved
drivers/serial/serial.c Outdated Show resolved Hide resolved
@yamt yamt marked this pull request as draft December 25, 2024 02:58
@yamt yamt marked this pull request as ready for review December 25, 2024 06:19
@yamt
Copy link
Contributor Author

yamt commented Jan 7, 2025

a reminder to myself: i have to look at the ci failure.

@yamt
Copy link
Contributor Author

yamt commented Jan 8, 2025

a reminder to myself: i have to look at the ci failure.

it was because of a wrong assertion. i removed the assertion.

@yamt
Copy link
Contributor Author

yamt commented Jan 9, 2025

rv-virt/citest64 failure looks like a stack overflow.

@yamt
Copy link
Contributor Author

yamt commented Jan 9, 2025

rv-virt/citest64 failure looks like a stack overflow.

i was able to reproduce the crash with today's master on local qemu.
#15478

@yamt
Copy link
Contributor Author

yamt commented Jan 10, 2025

rv-virt/citest64 failure looks like a stack overflow.

i was able to reproduce the crash with today's master on local qemu. #15478

rebased after #15478

@yamt
Copy link
Contributor Author

yamt commented Jan 10, 2025

rv-virt/citest64 failure looks like a stack overflow.

i was able to reproduce the crash with today's master on local qemu. #15478

rebased after #15478

it seems #15489 is also necessary.

@yamt
Copy link
Contributor Author

yamt commented Jan 14, 2025

rv-virt/citest64 failure looks like a stack overflow.

i was able to reproduce the crash with today's master on local qemu. #15478

rebased after #15478

it seems #15489 is also necessary.

rebased after #15489

fs/vfs/fs_uio.c Outdated Show resolved Hide resolved
* Make readv/writev implementations update struct uio
  This can simplify partial result handling.

* change the error number on the overflow from EOVERFLOW to EINVAL
  to match NetBSD

* add a commented out uio_offset field. I used "#if 0" here as
  C comments can't nest.

* add a few helper functions

Note on uio_copyfrom/uio_copyto:
although i'm not quite happy with the "offset" functionality,
it's necessary to simplify the adaptation of some drivers like
drivers/serial/serial.c, which (ab)uses the user-supplied buffer
as a line-buffer.
This would fix readv/writev issues mentioned in
apache#12674.
(only for this specific driver though. with this approach,
we basically have to fix every single drivers and
filesystems.)

Lightly tested on the serial console, using micropython REPL
on toywasm with esp32s3-devkit:toywasm, which used to be
suffered by the readv issue.
@xiaoxiang781216 xiaoxiang781216 merged commit 0001008 into apache:master Jan 14, 2025
39 checks passed
@anchao
Copy link
Contributor

anchao commented Jan 19, 2025

@yamt Can you share what problem you want to resolve with this patch? I am plan to revert this PR. serial device is not suitable for using uio to implement 1 byte copy, It’s too complicate.

@anchao
Copy link
Contributor

anchao commented Jan 19, 2025

@yamt Can you share what problem you want to resolve with this patch? I am plan to revert this PR. serial device is not suitable for using uio to implement 1 byte copy, It’s too complicate.

I don't understand the problem you mentioned in your other PR, or can you give me some code examples?

@anchao
Copy link
Contributor

anchao commented Jan 19, 2025

@yamt #15604

@yamt
Copy link
Contributor Author

yamt commented Jan 19, 2025

@yamt Can you share what problem you want to resolve with this patch? I am plan to revert this PR. serial device is not suitable for using uio to implement 1 byte copy, It’s too complicate.

IMO, it's simpler than having two cases.

I don't understand the problem you mentioned in your other PR, or can you give me some code examples?

#12674 (comment)
it usually ends up with readv with two iovecs.

@anchao
Copy link
Contributor

anchao commented Jan 19, 2025

@yamt Can you share what problem you want to resolve with this patch? I am plan to revert this PR. serial device is not suitable for using uio to implement 1 byte copy, It’s too complicate.

IMO, it's simpler than having two cases.

I don't understand the problem you mentioned in your other PR, or can you give me some code examples?

#12674 (comment) it usually ends up with readv with two iovecs.

@yamt setup micro-python is too heavy for me. Can you share some specific code or the calling point of readv in micro-python?

@anchao
Copy link
Contributor

anchao commented Jan 19, 2025

@yamt Can you share what problem you want to resolve with this patch? I am plan to revert this PR. serial device is not suitable for using uio to implement 1 byte copy, It’s too complicate.

IMO, it's simpler than having two cases.

I don't understand the problem you mentioned in your other PR, or can you give me some code examples?

#12674 (comment) it usually ends up with readv with two iovecs.

@yamt setup micro-python is too heavy for me. Can you share some specific code or the calling point of readv in micro-python?

So the root cause is, if using readv to read 2 vector buffers, the second read will block and cannot exit, right?

@anchao
Copy link
Contributor

anchao commented Jan 19, 2025

@yamt Can you share what problem you want to resolve with this patch? I am plan to revert this PR. serial device is not suitable for using uio to implement 1 byte copy, It’s too complicate.

IMO, it's simpler than having two cases.

I don't understand the problem you mentioned in your other PR, or can you give me some code examples?

#12674 (comment) it usually ends up with readv with two iovecs.

@yamt please help to review PR #15604 whether is works for you

@yamt
Copy link
Contributor Author

yamt commented Jan 20, 2025

@yamt Can you share what problem you want to resolve with this patch? I am plan to revert this PR. serial device is not suitable for using uio to implement 1 byte copy, It’s too complicate.

IMO, it's simpler than having two cases.

I don't understand the problem you mentioned in your other PR, or can you give me some code examples?

#12674 (comment) it usually ends up with readv with two iovecs.

@yamt setup micro-python is too heavy for me. Can you share some specific code or the calling point of readv in micro-python?

So the root cause is, if using readv to read 2 vector buffers, the second read will block and cannot exit, right?

yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Drivers Drivers issues Area: File System File System issues Size: M The size of the change in this PR is medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants